package com.ssy.lingxi.sms.entity;

import com.ssy.lingxi.sms.handler.converter.JpaJsonToMapConverter;
import lombok.Data;

import javax.persistence.*;
import java.util.HashMap;

/**
 * 短信服务器配置类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/10
 */

@Data
@Entity
@Table(schema = "public", name = "sms_config",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"serviceType"})},
        indexes = {@Index(name = "sms_config_status_idx", columnList = "status")})
public class SmsConfig {
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="config_seq")
    @SequenceGenerator(sequenceName="sms_config_seq", name="config_seq",allocationSize = 1)
    private Long id;

    /**
     * 其他资料-Json格式
     */
    @Convert(converter = JpaJsonToMapConverter.class)
    @Column(columnDefinition="jsonb")
    private HashMap<String,Object> config;

    /**
     * 服务商类型: 1-腾讯云，2-阿里云
     */
    @Column(columnDefinition = "int", nullable = false)
    private Integer serviceType;

    /**
     * 是否启用
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean status = true;

}
